package com.mystudy.quartzspringbootdemo.config;

import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

/**
 * <p>
 *  配置schedulerFactoryBean
 * </p>
 */
@Configuration
public class QuartzConfig implements SchedulerFactoryBeanCustomizer {

    /**
     * 设置 schedulerFactoryBean
     * @param
     */
    @Override
    public void customize(SchedulerFactoryBean schedulerFactoryBean) {
        //延时1秒启动定时任务
        //schedulerFactoryBean.setStartupDelay(1);
        //SchedulerFactoryBean在初始化后是否马上启动Scheduler，默认为true。如果设置为false，需要手工启动Scheduler
        schedulerFactoryBean.setAutoStartup(true);
        schedulerFactoryBean.setOverwriteExistingJobs(true);
    }

}
